from services.podcast_service import PodcastService
from config.settings import Config
from factories.character_factory import CharacterFactory

def main():
    """主函数"""
    print("AI播客生成器启动...")
    
    # 初始化服务
    podcast_service = PodcastService(
        llm_config=Config.LLM_CONFIG,
        tts_config=Config.TTS_CONFIG
    )
    
    # 创建角色
    character_factory = CharacterFactory()
    characters = character_factory.create_multiple_characters(Config.CHARACTER_CONFIGS)
    
    # 示例：生成单角色播客
    if characters:
        host = characters[0]
        print(f"正在生成单角色播客，角色: {host.name}")
        try:
            audio_data = podcast_service.generate_single_character_podcast(
                "人工智能的未来发展", 
                host
            )
            print(f"已生成单角色播客，音频数据长度: {len(audio_data) if audio_data else 0} 字节")
        except Exception as e:
            print(f"生成单角色播客时出错: {e}")
    
    # 示例：生成多角色播客
    if len(characters) >= 2:
        print(f"正在生成多角色播客，角色数量: {len(characters)}")
        try:
            audio_segments = podcast_service.generate_multi_character_podcast(
                "人工智能的未来发展",
                characters[:2]  # 使用前两个角色
            )
            print(f"已生成多角色播客，片段数量: {len(audio_segments)}")
        except Exception as e:
            print(f"生成多角色播客时出错: {e}")

if __name__ == "__main__":
    main()